<?php

include_once($_SERVER['DOCUMENT_ROOT'] . '/htqlmba/configs/database.php');

class LoaiDau extends Database {

    private $MA_LD;
    private $TEN_LD;
    private $TEN_LD_OLD;

    public function setMA_LD($MA_LD) {
        $this->MA_LD = $MA_LD;
    }

    public function getMA_LD() {
        return $this->MA_LD;
    }

    public function setTEN_LD($TEN_LD) {
        $this->TEN_LD = $TEN_LD;
    }

    public function getTEN_LD() {
        return $this->TEN_LD;
    }

    public function setTEN_LD_OLD($TEN_LD_OLD) {
        $this->TEN_LD_OLD = $TEN_LD_OLD;
    }

    public function getTEN_LD_OLD() {
        return $this->TEN_LD_OLD;
    }

    // function them tram
    public function themLD() {
        $query = "insert into loai_dau(MA_LOAI_DAU,TEN_LOAI_DAU) 
            values ('" . $this->getMA_LD() . "','" . $this->getTEN_LD() . "')";
        $this->setQuery($query);
        return $this->executeQuery();
    }

    public function suaLD() {
        $query = "	UPDATE `mba`.`may_bien_ap` 
						SET `TEN_LOAI_DAU` = '" . $this->getTEN_LD() . "' 
						WHERE `may_bien_ap`.`TEN_LOAI_DAU` = '" . $this->getTEN_LD_OLD() . "';";
        $this->setQuery($query);
        $this->executeQuery();


        $query = "	UPDATE `mba`.`loai_dau` 
						SET `TEN_LOAI_DAU` = '" . $this->getTEN_LD() . "' 
						WHERE `loai_dau`.`MA_LOAI_DAU` = '" . $this->getMA_LD() . "';";
        $this->setQuery($query);
        return $this->executeQuery();
    }

    public function xoaLD() {
        $this->setQuery("delete from loai_dau where  MA_LOAI_DAU='" . $this->getMA_LD() . "'");
        return $this->executeQuery();
    }

    public function dsLD() {
        $this->setQuery("select MA_LOAI_DAU,TEN_LOAI_DAU
							 from loai_dau
ORDER BY `loai_dau`.`MA_LOAI_DAU`  DESC
							 ");
        return $this->fetchAll();
    }

}

?>